-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Apply Flexible Types to Symbols from files compiled without Explicit Nulls #22473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+53
−14
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
olhotak
approved these changes
Apr 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, but @noti0na1 can you also have a look?
noti0na1
approved these changes
Apr 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
noti0na1
added a commit
that referenced
this pull request
Apr 13, 2025
noti0na1
added a commit
that referenced
this pull request
Aug 22, 2025
A fixed version of #22473 This PR wraps the types of symbols from files compiled without explicit nulls in flexible types. This allows for interop between multiple files in cases where ```scala class Unsafe_1 { def foo(s: String): String = { if (s == null) then "nullString" else s } } ``` compiled without explicit nulls can still be used in ```scala def Flexible_2() = val s2: String | Null = "foo" val unsafe = new Unsafe_1() val s: String = unsafe.foo(s2) unsafe.foo("") unsafe.foo(null) ``` whereas the argument would have been a strictly non-null String, because of the flexible type, the function call is now permitted. Some explicit nulls neg tests have been excluded under the scala2 library tasty tests due to technical reasons, for example: ```scala class S { given Conversion[String, Array[String]] = _ => ??? def f = { val s: String | Null = ??? val x: String = s // error val xl = s.length // error val xs: Array[String | Null] | Null = s // error } } ``` `val xl = s.length` will not give an error. This is because the .length function is from the WrappedString.scala library. After desugaring, it will become `wrapString(s).length`. Since the scala2 library is compiled without explicit nulls, the types are flexified.`wrapString` will have argument type FlexibleType(String) and return type FlexibleType(String), therefore it will not give an error. Hence we need to exclude it from the tasty tests. [test_scala2_library_tasty]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR wraps the types of symbols from files compiled without explicit nulls in flexible types.
This allows for interop between multiple files in cases where
compiled without explicit nulls can still be used in
whereas the argument would have been a strictly non-null String, because of the flexible type, the function call is now permitted.